package com.zhuang.principle.inversion;



/**
 * @Classname DependenceInversion1
 * @Description 依赖倒转原则错误示范
 * @Date 2021/3/15 13:20
 * @Created by dell
 */

public class DependenceInversion1 {
    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());
    }
}

//定义接口
interface IReceiver{
    public String getInfo();
}

class WeiXin implements IReceiver{
    @Override
    public String getInfo() {
        return "发送微信消息...";
    }
}
class Email implements IReceiver{
    @Override
    public String getInfo() {
        return "发送邮件消息...";
    }
}
//对接口的依赖
class Person{
    public void receive(IReceiver receiver){
        System.out.println(receiver.getInfo());
    }
}
